package com.yzl.meeting.business.entity;

import java.util.List;

/**
 * 用来向客户端传递分页数据的对象
 * @param <T>
 */
public class PageBean<T> {
    private int currentPage; //当前页码
    private int pageSize; //每页记录数
    //private int totalPages; //总页数
    private int totalRecords; //总记录数
    private List<T> datas; //每页的具体数据
    private String url;//记录请求的路径(包括请求参数)

    /**
     * 获取总页数
     * @return
     */
    public int getTotalPages() {
        int tp = totalRecords/pageSize;
        return totalRecords%pageSize==0?tp:tp+1;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public int getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getTotalRecords() {
        return totalRecords;
    }

    public void setTotalRecords(int totalRecords) {
        this.totalRecords = totalRecords;
    }

    public List<T> getDatas() {
        return datas;
    }

    public void setDatas(List<T> datas) {
        this.datas = datas;
    }

    @Override
    public String toString() {
        return "PageBean{" +
                "currentPage=" + currentPage +
                ", pageSize=" + pageSize +
                ", totalRecords=" + totalRecords +
                ", datas=" + datas +
                '}';
    }
}
